home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / hard / drivr / addspeed.lha / AddSpeed.s < prev    next >
Text File  |  1992-02-08  |  4KB  |  264 lines

  1. * Written By Niklas Sjöberg, 2:203/415.3
  2. * Exitlevels :
  3. * NO-DOS         Equ 30
  4. * NO Adspeed        Equ 5    Equ    No FAST-mem
  5. * Failed to switch    Equ 10
  6.  
  7. *  Assemble with GenAm version 3.
  8.  
  9.         opt    NOCHKPC
  10.         OUTPUT    ram:AddSpeed
  11.         
  12.         include include:IDir.i
  13.         
  14.         include "exec/memory.i"
  15.         include    "exec/exec_lib.i"
  16.         include    "libraries/dos_lib.i"
  17.         include "libraries/dos.i"
  18.  
  19.         include "include:misc/easystart.i" ; WB-startup.
  20.         
  21. Print        MACRO
  22.         lea    \1(PC),a1
  23.         lea    \1_end(PC),a2
  24.         suba.l    a1,a2
  25.         move.l    a1,d2            ;buf
  26.         move.l    a2,d3            ;len
  27.         tst.l    winhd
  28.         beq    \@
  29.         move.l    winhd(PC),d1
  30.         bra    \@w
  31. \@        CALLDOS    Output
  32.         move.l    d0,d1
  33. \@w        CALLDOS    Write
  34.         ENDM
  35.  
  36. Upper        MACRO
  37.         moveq    #\2,d0
  38.         subq.w    #1,d0
  39.         move.l    a3,-(SP)
  40. konv        
  41.         cmp.b    #97,(\1)
  42.         blo    ut_k
  43.         cmp.b    #122,(\1)
  44.         bhi    ut_k
  45.         sub.b    #32,(a3)
  46. ut_k        move.b    (a3)+,d1
  47.         dbf    d0,konv
  48.         move.l    (SP)+,a3
  49.         ENDM
  50.  
  51.  
  52. Bold        MACRO
  53.         dc.b $9b,'1;31;40m'
  54.         ENDM
  55.  
  56.         
  57. Norm        MACRO
  58.         dc.b $9b,'0;31;40m'
  59.         ENDM
  60.     
  61. ** EXEC LIBRARY
  62. Exec        Equ    $00000004
  63. OpenLib        Equ    -408
  64.  
  65. ** DOS LIBRARY
  66. Open        Equ    -30
  67. Close        Equ    -36
  68. Read        Equ    -42
  69. Write        Equ    -48
  70. Input        Equ    -54
  71. Output        Equ    -60
  72. Seek        Equ    -66
  73. Delay        Equ    -198
  74. Execute     Equ    -222
  75.  
  76. ** DOS STUFF
  77. Mode_Old    Equ    1005
  78. Mode_New    Equ    1006
  79. Mode_Read_Write Equ    1004
  80. Dos_Secs    Equ    60        *1/60 of secs 
  81. **********************************************************************
  82.  
  83.  
  84. start        move.l    d0,d6            ;len
  85.         move.l    a0,a3            ;start
  86.         
  87.         CALLEXEC Forbid        
  88.         moveq    #0,d0
  89.         lea    Dosname(PC),a1
  90.         CALLEXEC OpenLibrary
  91.         tst.l    d0
  92.         bne    ok_dos
  93.         moveq    #30,d0
  94.         bra    err
  95.  
  96.         
  97. ok_dos        move.l    d0,_DOSBase
  98.         Print    About
  99.         tst.l    returnMsg
  100.         beq    from_CLI
  101.         move.l    #win,d1
  102.         move.l    #MODE_OLDFILE,d2
  103.         CALLDOS    Open
  104.         tst.l    d0
  105.         beq    err
  106.         move.l    d0,winhd
  107.         lea    foo(pc),a3
  108.         moveq    #0,d1
  109.         bsr    speed_test
  110.         cmp.w    #$1500,d1
  111.         bhs    off
  112.         move.w    #'ON',(a3)
  113.         bra    from_CLI
  114. off        move.w    #'OF',(a3)
  115.  
  116.  
  117. from_CLI    
  118.          moveq    #MEMF_FAST,d1
  119.          CALLEXEC AvailMem
  120.          bne    fastmem_ok
  121.         Print    need_fast
  122.         moveq    #5,d0
  123.         bra    err
  124. fastmem_ok
  125.         moveq    #0,d1
  126.         bsr    speed_test
  127.         cmp.w    #$1500,d1
  128.         blo.s    p_slow
  129.         Print    run_14
  130.         bra    test_par
  131.  
  132. p_slow        Print    run_7
  133.  
  134. test_par    subq.w    #1,d6
  135.         bne    par_ok
  136. wrong_par    Print    par
  137.         bra    out
  138.         
  139. par_ok        Upper    a3,2
  140.         moveq    #0,d6
  141.         cmp.w    #'ON',(a3)
  142.         bne    no_on
  143.         moveq    #1,d6        ;on
  144. no_on        cmp.w    #'OF',(a3)
  145.         bne    no_off
  146.         moveq    #2,d6
  147.  
  148. no_off        tst.b    d6
  149.         beq    wrong_par
  150.         moveq    #0,d1
  151.         bsr    speed_test
  152.         cmp.w    #$1500,d1
  153.         blo    slow
  154.         move.w    #0,$b10000    ;Turn AdSpeed OFF and test
  155.         move.l    d1,d2
  156.         moveq    #0,d1
  157.         bsr    speed_test
  158.         move.w    #0,$b00000    ;Restore
  159.         sub.w    d1,d2
  160.         cmp.w    #1000,d2
  161.         bhi    Adspeed_Installed
  162.         Print     no_ad
  163.         moveq    #5,d0
  164.         bra    err
  165.         
  166. slow        move.l    d1,d2
  167.         move.w    #0,$b00000    ;Turn AdSpeed ON and test
  168.         moveq    #0,d1
  169.         bsr    speed_test
  170.         move.w    #0,$b10000    ;Restore
  171.         sub.w    d2,d1
  172.         cmp.w    #1000,d1
  173.         bhi    Adspeed_Installed
  174.         Print    no_ad
  175.         moveq    #5,d0
  176.         bra    err
  177.                         
  178. Adspeed_Installed
  179.         cmp.b    #1,d6        ;ON?
  180.         bne    not_on
  181.         Print    on_14
  182.         move.w    #0,$b00000
  183.         moveq    #0,d1
  184.         bsr    speed_test
  185.         cmp.w    #$1500,d1
  186.         bhi    not_off
  187.         Print    fail_14
  188.         moveq    #10,d0
  189.         bra    err
  190.         
  191. not_on        cmp.b    #2,d6        ;OFF
  192.         bne    not_off
  193.         Print    on_7
  194.         move.w    #0,$b10000
  195.         moveq    #0,d1
  196.         bsr    speed_test
  197.         cmp.w    #$1500,d1
  198.         blo    not_off
  199.         Print    fail_7
  200.         moveq    #10,d0
  201.         bra    err        
  202. not_off
  203. out        moveq    #0,d0
  204. err        CALLEXEC Permit
  205.         tst.l    winhd
  206.         beq    no_close
  207.         moveq    #2*50,d1
  208.         CALLDOS    Delay
  209.         move.l    winhd(pc),d1
  210.         CALLDOS    Close
  211. no_close    rts
  212.         
  213.  
  214.         
  215. speed_test    cmp.b    #$01,$dff006
  216.         bne.s    speed_test
  217. cnt        addq.w    #1,d1
  218.         cmp.b    #$fd,$dff006
  219.         bne.s    cnt
  220.         rts
  221.         
  222.         
  223.  
  224. _DOSBase    dc.l    0
  225. Dosname        DOSNAME
  226.         even
  227. About        Bold
  228.         dc.b    'Speed (c) 1992 by Niklas Sjöberg, reachable via 2:203/415.3@Fidonet.',10,13
  229.         Norm
  230. About_end
  231. par        dc.b    'Usage: Speed [ON/OFF]',10,13
  232. par_end
  233.  
  234. no_ad        dc.b    'You have no AdSpeed!!',10,13
  235. no_ad_end
  236.  
  237. fail_14        dc.b    'Failed to switch to 14 Mhz!',10,13
  238. fail_14_end
  239.  
  240. fail_7        dc.b    'Failed to switch to 7 Mhz!',10,13
  241. fail_7_end
  242.  
  243. on_14        dc.b    'Switching into 14 Mhz mode (wroom)',10,13
  244. on_14_end
  245. on_7        dc.b    'Swtiching into  7 Mhz mode (sigh!)',10,13
  246. on_7_end
  247.  
  248. run_14        dc.b    'State: 14 Mhz',10,13
  249. run_14_end
  250.  
  251. run_7        dc.b    'State:  7 Mhz',10,13
  252. run_7_end
  253.  
  254. need_fast    dc.b    'Need fastmem! AdSpeed makes no differnce'
  255.         dc.b    ' otherwise!',10,13
  256. need_fast_end
  257.  
  258.  
  259. win        dc.b    'CON:10/10/400/100/AdSpeed Window',0
  260.         even
  261. winhd        dc.l    0
  262. foo        ds.w    1
  263.  
  264.